using System;

namespace StringCalculator
{
    public class StringCalculator
    {
        public static int AddNumber(string input)
        {
            if(string.IsNullOrEmpty(input))
                return 0;
            else
            {
                var delimiters = new char[3];
                delimiters[0] = ',';
                delimiters[1] = '\n';

                if(input.StartsWith("//"))
                {
                    delimiters[2] = char.Parse(input.Substring(2, 1));
                    input = input.Substring(3);
                }

                var array = input.Split(delimiters);
                var result = 0;

                foreach (var items in array)
                {
                    if (string.IsNullOrEmpty(items))
                        throw new ArgumentException("Invalid input for AddNumber");
                    result += int.Parse(items);
                }
                return result;
            }
        }
    }
}